package com.qcit.user.bean.common

import android.widget.EditText
import android.widget.TextView
import com.qcit.common.view.InputMenuView
import java.lang.Exception

fun EditText.valueEmpty(): Boolean {
    if (this.text == null || this.text.toString() == "")
        return true
    return false
}

fun TextView.valueEmpty(): Boolean {
    if (this.text == null || this.text.toString() == "")
        return true
    return false
}

fun TextView.value(): String {
    try {
        return this.text.toString()
    } catch (e: Exception) {
        return "";
    }
}

fun EditText.value(): String {
    try {
        return this.text.toString()
    } catch (e: Exception) {
        return "";
    }
}

fun EditText.valueEqual(edit: EditText): Boolean {
    try {
        if (edit.text.toString().equals(this.text.toString()))
            return true
    } catch (e: Exception) {
    }
    return false
}

fun TextView.valueEqual(edit: TextView): Boolean {
    try {
        if (edit.text.toString().equals(this.text.toString()))
            return true
    } catch (e: Exception) {
    }
    return false
}

fun InputMenuView.value():String{
    try{
        return this.getText()
    }catch (e:Exception){
        return ""
    }
}
fun InputMenuView.valueEqual(in2:InputMenuView):Boolean{
    try{
        return this.value().equals(in2.value())
    }catch (e:Exception){
        return false
    }
}
fun InputMenuView.empty():Boolean{
    val value=this.value()
    return value.empty()
}